<script setup lang='ts'>
  import { onMounted, reactive } from 'vue';
  import { propApi } from '@/api/controller';
  import { Toastloading } from '@/utils/public';
  import { getPlayEndTime, getDateArray } from '@/utils'
  const action = reactive({
    list:[] as any[],
    gift_id:'',
    dateArr:getDateArray('ymdhis') as Array<number>
  })
  const resetQuery = ()=>{
    action.gift_id = ''
    action.dateArr = getDateArray('ymdhis') as Array<number>
    getList()
  }
  const getList = async()=> {
    const loading = Toastloading()
    const timeObi = getPlayEndTime(action.dateArr)
    const res = await propApi.luckGiftAllStatistics({
      gift_id:action.gift_id,
      created_st:timeObi.playTime,
      created_ed:timeObi.endTime
    })
    loading.close()
    const { data={} } = res
    action.list = [data]
  }
  onMounted(()=>{
    getList()
  })
</script>

<template>
  <div class="xm-content">
    <div class="xm-headTab">
      <div class="labelBox">
        <div class="labelItem">
          <div class="label">礼物ID：</div>
          <el-input v-model="action.gift_id" placeholder="请输入礼物ID" />
        </div>
        <div class="labelItem">
          <div class="label">日期：</div>
          <el-date-picker
            v-model="action.dateArr"
            type="datetimerange"
            format="YYYY-MM-DD HH:mm:ss "
            value-format="YYYY-MM-DD HH:mm:ss"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
          />
        </div>
        <div class="labelItem">
          <el-button type="primary" @click="getList">查询</el-button>
          <el-button type="primary" @click="resetQuery">重置</el-button>
        </div>
      </div>
    </div>
    <el-table
      class="xm-main xm-TableCenter"
      :data="action.list"
      border>
      <el-table-column min-width="120" prop="userNum" label="人数" />
      <el-table-column min-width="120" prop="useNum" label="消耗钻石数" />
      <el-table-column min-width="120" prop="rewardNum" label="产出钻石数" />
      <el-table-column min-width="120" prop="divideNum" label="主播分成钻石数" />
      <el-table-column min-width="120" prop="profitNum" label="利润钻石数" />
      <el-table-column min-width="120" prop="profitYun" label="利润元" />
      <el-table-column min-width="120" prop="profitRate" label="利润率">
        <template #default="scope">
          {{ scope.row.profitRate }}%
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>